<?php
    /**
    * Ward save
    * For HuyBDS Project
    * 
    * @author: trungdt
    * @version: 1.0
    * 
    */
    if (!defined("EXPONENT")) exit("");
    $ring = null;		
    if (isset($_POST['id'])) {
        $ring = $db->selectObject('provinces_wards', 'id='.intval($_POST['id']));
    } else {
    }
    $pid=-1;
    if (isset($_REQUEST['pid']))
    {
        $pid=intval($_REQUEST['pid']);
    }
    $province=$db->selectObject("provinces","id=".$pid);
    if ($province && exponent_users_isLoggedIn()) {
        $ring= rsmanage_item::ward_update($_POST, $ring);
        $ring->pid=$province->id;
        if (isset($ring->id)) {
            // calculate all song length
            $db->updateObject($ring,"provinces_wards");
        } else {
            // save ID for later use :)
            $ring->id=$db->insertObject($ring,"provinces_wards");
        }	
        exponent_flow_redirect(SYS_FLOW_ACTION);
        //redirect_to($url);
    } else {
        echo SITE_403_HTML;
    }


?>
